package com.monlyu.bean;

import org.apache.commons.lang.BooleanUtils;

import com.monlyu.config.AppArgs;
import com.monlyu.util.StringUtil;

/**
 * 数据库的相关记录保存
 * 
 * @author monlyu
 * @since 2010-1-7
 */
public class DataBaseBean {

	private String dbName;
	private String name;
	private String version;
	private String encoding;
	private boolean commenOn;

	public DataBaseBean() {
	}

	public DataBaseBean(String name, String version, boolean commenOn) {
		this.name = name;
		this.version = version;
		this.commenOn = commenOn;
	}

	public String getName() {
		return name;
	}

	public String getEncoding() {
		return encoding;
	}

	public void setEncoding(String encoding) {
		this.encoding = encoding;
	}

	public void setName(String name) {
		if (StringUtil.isEmpty(name)) {
			name = AppArgs.DB_MYSQL;
		} else {
			if (name.equalsIgnoreCase(AppArgs.DB_ORACLE)) {
				name = AppArgs.DB_ORACLE;
			} else if (name.equalsIgnoreCase(AppArgs.DB_SQLSERVER)) {
				name = AppArgs.DB_SQLSERVER;
			} else {
				name = AppArgs.DB_MYSQL;
			}
		}
		this.name = name;
	}

	public String getVersion() {
		return version;
	}

	public void setVersion(String version) {
		this.version = version;
	}

	public boolean isCommenOn() {
		return commenOn;
	}

	public void setCommenOn(boolean commenOn) {
		this.commenOn = commenOn;
	}

	public void setCommenOn(String commenOn) {
		setCommenOn(BooleanUtils.toBoolean(commenOn));
	}

	public String getDbName() {
		return dbName;
	}

	public void setDbName(String dbName) {
		this.dbName = dbName;
	}
}
